//万昱柔 2025/3/10   
import { MaxScore } from "./Common";
cc.Class({
    extends: cc.Component,

    properties: {
        curLabel: cc.Label,
        maxLabel: cc.Label,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        this.curScore = 0;
        this.maxScore = cc.sys.localStorage.getItem(MaxScore) || 0;
        cc.curScore = this.curScore;
        this.showData();

    },

    // start() {

    // },

    addScore() {
        this.curScore += 10;
        if (this.curScore > this.maxScore) {
            this.maxScore = this.curScore;
            cc.sys.localStorage.setItem(MaxScore, this.maxScore);
        }
        this.showData();
        //更新数据
        //渲染数据
        cc.curScore = this.curScore;


    },

    showData() {
        this.curLabel.string = "当前得分：" + this.curScore;
        this.maxLabel.string = "最高得分：" + this.maxScore;
    },


    // update (dt) {},
});
